package main

import (
	"github.com/gin-gonic/gin"
	"go-api-template/common"
	"go-api-template/controllers"
)

var Handler *gin.Engine

func Boot() {
	gin.SetMode(gin.ReleaseMode)
	Handler = gin.Default()
	base := Handler.Group("/api/v1")
	registerRouter(base)
	Handler.Use(common.Recovery())
}

func registerRouter(g *gin.RouterGroup) {
	controller := controllers.NewUserController()
	g.POST("/user/list", common.AutoHandler(controller, "QueryPage"))
	g.POST("/user/create", common.AutoHandler(controller, "Create"))
	g.PUT("/user/update/:id", common.AutoHandler(controller, "Update"))
	g.GET("/user/find/:id", common.AutoHandler(controller, "Find"))
	g.DELETE("/user/delete/:id", common.AutoHandler(controller, "Delete"))
}
